CXX := clang++
LDFLAGS := -lcap
TARGET := WSLGd
SRC_DIRS := .
INSTALL := install -p
INSTALL_PREFIX= $(DESTDIR)/$(PREFIX)/bin

SRCS := $(shell find $(SRC_DIRS) -name "*.cpp" -or -name "*.c" -or -name "*.s")
OBJS := $(addsuffix .o,$(basename $(SRCS)))
DEPS := $(OBJS:.o=.d)

INC_DIRS := $(shell find $(SRC_DIRS) -type d)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))

CPPFLAGS := $(INC_FLAGS) -MMD -MP -std=c++17

$(TARGET): $(OBJS)
	$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(LOADLIBES) $(LDLIBS)

.PHONY: clean
clean:
	$(RM) $(TARGET) $(OBJS) $(DEPS)

install:
	$(INSTALL) $(TARGET) $(INSTALL_PREFIX)

-include $(DEPS)